package com.snow.useviewdemo.view

import android.content.Context
import android.graphics.Canvas
import android.graphics.Color
import android.graphics.Paint
import android.util.AttributeSet
import android.util.Log
import android.view.View
import com.snow.useviewdemo.R

/**
 * Created by zhaoyingtao
 * Date: 2021/10/21
 * Describe:
 */
class PaintTestView : View {
    var mPaint1: Paint? = null
    var mPaint2: Paint? = null
    var mPaint3: Paint? = null

    constructor(context: Context) : this(context, null)

    constructor(context: Context, attributes: AttributeSet?) : super(context, attributes) {
        Log.e("PaintTestView", "=================constructor=")
        mPaint1 = Paint()
        mPaint1?.isAntiAlias = true
        mPaint1?.color = resources.getColor(R.color.color_red)

        mPaint2 = Paint()
        mPaint2?.isAntiAlias = true
        mPaint2?.color = Color.parseColor("#FD674F")

        mPaint3 = Paint()
        mPaint3?.isAntiAlias = true
        mPaint3?.color = resources.getColor(R.color.color_red_100)

    }

    init {
        Log.e("PaintTestView", "=================init=")
    }

    override fun onDraw(canvas: Canvas?) {
        super.onDraw(canvas)
        mPaint1?.let { canvas?.drawCircle(100f, 100f, 50f, it) }
        mPaint2?.let { canvas?.drawCircle(100f, 200f, 50f, it) }
        mPaint3?.let { canvas?.drawCircle(100f, 300f, 50f, it) }
    }
}